//
//  ViewController.m
//  本地缓存
//
//  Created by 崔博 on 2018/9/19.
//  Copyright © 2018年 崔博. All rights reserved.
//

#import "ViewController.h"
#import <sys/xattr.h>
@interface ViewController ()

@end

@implementation ViewController

/**
 Documents (backup 备份)
 {
 大文件要做 非备份设置 （如视频文件，多媒体文件）
 
 }
 Library
 1.Caches {
    系统的缓存存放在这个文件夹
 }
 2.Prefernce (back up备份)NSUserDefalt
 temp: 临时文件（系统会不定期的删除里面文件）
 */
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}
- (void)getChain
{
    NSMutableDictionary * coditiongDic = [NSMutableDictionary dictionary];
    [coditiongDic setObject:@"123" forKey:(id)kSecClassKey];
    CFDataRef data = NULL;
    SecItemCopyMatching((CFDictionaryRef)coditiongDic, (CFTypeRef *)&data);
}
- (void)savekeyChain
{
    //
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    
    // 数据类型
    // kSecClassInternetPassword 互联网密码
    
    // kSecClassGenericPassword 通用密码
    
    // kSecClassCertificate 证书
    
    // kSecClassKey 秘钥
    
    // kSecClassIdentity 身份ID
    NSString *pass = @"123456";
    [dic setObject:[pass dataUsingEncoding:NSUTF8StringEncoding] forKey:(id)kSecClassKey];
    // 查询设置条件
    OSStatus status = SecItemAdd((CFDictionaryRef)dic, NULL);
    if (status == noErr) {
        NSLog(@"sucess");
    }else
    {
        NSLog(@"%d",status);
    }
    
}
// 是否缓存
//- (BOOL)addSkipBackAttributeToItemAturl:(NSURL *)url
//{
//    NSString * filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) firstObject];
//    NSURL * url = [NSURL URLWithString:filePath];
//
//    const char * filePath = [[url path] fileSystemRepresentation];
//    const char * attName = "com.apple.MoblieBack";
//    u_int8_t attribute = 1;
//    int resule = setxattr(filePath, attName, &attribute, sizeof(attribute), 0, 0);
//    return 0;
//}



@end
